Predicates and truth values

Conditional expressions in T (see section [*]) usually involve the evaluation of a test expression; the object yielded by the test is then used to make a control decision, depending on whether the value is false or true. There is one distinguished false value called #F. Any other value is considered to be true. A value intended to be used in this way is called a boolean or truth value.

A predicate is any procedure which yields truth values. Predicates are typically given names which end in ?, e.g. NULL? and EQ?. Calls to predicates are naturally used as test expressions.

An equality predicate is a two-argument predicate which is side-effectless and unaffected by side-effects, and acts like an equivalence relation in the mathematical sense.

The canonical boolean objects have convenient read syntax associated with them.

#T reads as true Read syntax


\begin{inset}{}
Read syntax for canonical {\it true} object.
\end{inset}

#F reads as false Read syntax


\begin{inset}{}
Read syntax for canonical {\it false} object.
\begin{codexenv}
...
...))) &$\Longrightarrow$\ & {\it true} \\
\end{tabular} \end{codexenv}\end{inset}

() reads as empty-list Read syntax


\begin{inset}{}
Read syntax for {\it empty-list} object.
\end{inset}


\begin{inset}{}
This system variable has as its value the canonical false object \char93 {\tt F}.
\end{inset}


\begin{inset}{}
The system variable {\tt T} has as its value the canonical true ...
... non-false value is considered to be true for the purposes of tests.
\end{inset}

(), #T, and #F are elements of read syntax, not evaluatable symbols.
\begin{codexenv}
\begin{tabular}{lll}
(car '(\char93 {\tt T} foo)) & $\Longrigh...
... future:} () & $\Longrightarrow$\ & {\it error} \\
\end{tabular} \end{codexenv}

In T3, the canonical false value '#F is not necessarily the same object as the empty list, (). For compatibility with previous versions, in T3.1 false and the empty list will continue to be the same object, but this will change in a future release.
\begin{codexenv}
(eq? '\char93 {\tt F} '()) $\longrightarrow$\ {\it undefined} \\
\end{codexenv}
In T3.1 (eq? #F () $\Longrightarrow$ true').

It is an error to use () in an evaluated position. This error currently generates a warning and treats () as '(), i.e. as if the empty list were self evaluating. An error will be signalled in the future. Use '() for empty lists, and NULL? to check for the empty list. NIL or '#F can be used for false values, and NOT to check for false values.